package com.allwees.bs.module.core.req;

import com.allwees.bs.core.modelbase.req.Req;
import com.allwees.bs.core.modelbase.validate.ValidateItem;
import com.allwees.core.common.constant.EAuditResult;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.apache.commons.lang3.StringUtils;

/**
 * @author yangylsky
 * @since 2019-12-16
 */
@Data
@EqualsAndHashCode(callSuper = true)
public class BaseAuditReq extends Req {
    protected EAuditResult result;

    protected String reason;

    protected String remark;

    protected String[] photos;

    @Override
    public ValidateItem[] getValidateItems() {
        return new ValidateItem[]{
                new ValidateItem(result == null, "审核结果不能为空"),
                new ValidateItem(EAuditResult.REJECTED == result && (StringUtils.isBlank(reason) && StringUtils.isBlank(remark)), "必须填写审核拒绝原因或备注")
        };
    }

    public Boolean isApproved() {
        return EAuditResult.APPROVED.equals(result);
    }
}
